﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Video.aspx.cs" Inherits="KioskosJugandoLimpio.Denuncias.Video" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<a href="Denuncias.aspx" class="botonAtras">Atras</a><br/><br/>
    <script language="JavaScript" type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
    <script language="JavaScript" type="text/javascript">
<!--

        // Global variable to hold player's reference.
        var _Nimbb;

        // Global variable to hold the guid of the recorded video.
        var _Guid = "";

        // Global variables for timer.
        var _Timer;
        var _Count;

        // Constant for maximum recording time (in seconds).
        var MAX_TIME = 120;

        // Event: Nimbb Player has been initialized and is ready.
        function Nimbb_initCompleted(idPlayer) {
            // Get a reference to the player since it was successfully created.
            _Nimbb = document[idPlayer];
        }

        // Event: the player has stopped recording.
        function Nimbb_recordingStopped(idPlayer) {
            // Tell the player to save video now.
            _Nimbb.saveVideo();
        }

        // Event: the state of the player changed.
        function Nimbb_stateChanged(idPlayer, state) {
            // Update button text.
            updateText();
        }

        // Event: the video was saved.
        function Nimbb_videoSaved(idPlayer) {
            var textbox = document.getElementById("guidTextBox");

            // Get video GUID.
            _Guid = _Nimbb.getGuid();

            // Set GUID value in textbox.
            //textbox.value = _Guid;
           // alert("<iframe src='Video.aspx?ajax=1&guid=" + _Guid + "' width='0' height='0'>");
            $("body").append("<iframe src='Video.aspx?ajax=1&guid="+_Guid+"' width='0' height='0'>")
        }

        // Event: the timer count.
        function Timer_Count() {
            // Decrement total count and check if we have reached the maximum time.
            _Count--;
            if (_Count == 0) {
                // Stop the recording.
                stop();
                return;
            }

            // Update button text.
            updateText();

            // Let's continue the timer.
            _Timer = setTimeout("Timer_Count()", 1000);
        }

        // Called when user clicks the link.
        function action() {
            // Check player's state and call appropriate action.
            if (_Nimbb.getState() == "recording") {
                stop();
            }
            else {
                record();
            }
        }

        // Start recording the video.
        function record() {
            // Make sure the user has allowed access to camera.
            if (!_Nimbb.isCaptureAllowed()) {
                alert("Por favor selecciona que si das permiso de grbar.");
                return;
            }

            // Make sure the user is not already recording.
            if (_Nimbb.getState() == "recording") {
                alert("Ya estas grabandoo.");
                return;
            }

            // Prepare timer object.
            _Count = MAX_TIME + 1;
            Timer_Count();

            // Start recording.
            _Nimbb.recordVideo();
        }

        // Stop recording the video.
        function stop() {
            // Make sure the user is recording.
            if (_Nimbb.getState() != "recording") {
                alert("No has grabado nada.");
                return;
            }

            // Stop timer.
            clearTimeout(_Timer);

            // Stop recording.
            _Nimbb.stopVideo();
        }

        // Update text on the link.
        function updateText() {
            var actionButton = document.getElementById("actionButton");

            // Check player's state.
            if (_Nimbb.getState() == "recording") {
                // Update link text.
                actionButton.innerHTML = "<img src='../Images/grabar.png' alt='grabar'/>parar (" + _Count + ")";
            }
            else {
                actionButton.innerHTML = "<img src='../Images/grabar.png' alt='grabar'/>Grabar";
            }
        }

// -->
    </script>
    <div id="contenido">
        <div id="informacionVideo">
            <p class="infoGrande">
                Le informamos que Usted cuenta con 2(dos) minutos para su grabación, es importante
                decir su nombre, un teléfono en el que podamos contactarlo (a), el motivo de la
                queja/denuncia así como el nombre del funcionario público implicado.
            </p>
        </div>
        <div id="videoDiv">
            <object id="nimbb" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                width="320" height="240" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
                <param name="movie" value="http://player.nimbb.com/nimbb.swf?mode=record&showmenu=0&simplepage=1&key=2c9b347d5b" />
                <param name="allowScriptAccess" value="always" />
                <param name="allowFullScreen" value="true" />
                <embed name="nimbb" src="http://player.nimbb.com/nimbb.swf?mode=record&showmenu=0&simplepage=1&key=2c9b347d5b" width="320" height="240" allowscriptaccess="always" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer"></embed>
            </object>
            <a id="actionButton" href="javascript:action();"><img src="../Images/grabar.png" alt="grabar"/>Grabar</a>
        </div>
    </div>
   <div id="abajo">
        <p class="advertencia">
            LA INFORMACIÓN QUE SEA GRABADA SERA CONFIDENCIAL Y POR NINGÚN MOTIVO SERÁ MOSTRADA
            A LA OPINIÓN PÚBLICA
        </p>
    </div>
</asp:Content>
